package xxl.robotlegs.framework.impl 
{
	import xxl.robotlegs.framework.api.IMatcher;
	/**
	 * ...
	 * @author XXL
	 */
	public class ObjectProcessor 
	{
		private const _handlers:Vector.<ObjectHandler> = new Vector.<ObjectHandler>;
		
		public function addObjectHandler(matcher:IMatcher, handler:Function):void
		{
			_handlers.push(new ObjectHandler(matcher, handler));
		}
		
		public function processObject(object:Object):void
		{
			const len:int = _handlers.length;
			for (var i:int = 0; i < len; i++) 
			{
				_handlers[i].handle(object);
			}
		}
		
	}

}
import xxl.robotlegs.framework.api.IMatcher;

class ObjectHandler
{
	private var _matcher:IMatcher;
	private var _handler:Function;
	
	public function ObjectHandler(matcher:IMatcher, handler:Function)
	{
		_matcher = matcher;
		_handler = handler;
	}
	
	public function handle(object:Object):void
	{
		_matcher.matches(object) && _handler(object);
	}
}